unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Windows,Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,regexpr;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Memo1: TMemo;
    Memo2: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private

  public

  end;

var
  Form1: TForm1;
  Rgr: TRegExpr;
implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
begin
  Memo2.Clear;
  try
    Rgr:=TRegExpr.Create;
    // 遍历Memo1中的每一行
    for i := 0 to Memo1.Lines.Count - 1 do
    begin
      OutputDebugString(PChar(Memo1.Lines[i]));
      Rgr.Expression:=Trim(Edit1.Text);
      if Rgr.Exec(Memo1.Lines[i]) then
      begin
        OutputDebugString(PChar('True'));
        repeat
          Memo2.Lines.Add(Rgr.Match[0]);
        until not Rgr.ExecNext;
      end;
    end;


  finally
    Rgr.Free;
  end;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  Memo1.Clear;
  Memo1.Lines.Add('Documents\Lazarus\JSExtension\bin\dist\qiuA/shiyan1/sound/BGM.mp3');
  Memo1.Lines.Add('Documents\Lazarus\JSExtension\bin\dist\qiuA/shiyan1/images/con0wietu_17.jpg');
  Memo1.Lines.Add('Documents\Lazarus\JSExtension\bin\dist\qiuA/shiyan1/sound/BGM.mp3.bak');
end;

end.

